package com.aisino.springai;

import cn.hutool.core.io.resource.ResourceUtil;
import org.apache.tika.Tika;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;

public class TikaExample {
    public static void main(String[] args) throws IOException {
        Tika tika = new Tika();
         // 或PDF文件
        InputStream stream = ResourceUtil.getStream("data.docx");
        File file = new File("C:\\Users\\Aisino丶\\Desktop\\project\\spring_ai_demo\\springAI\\src\\main\\resources\\data.docx");
        try {
            String content = tika.parseToString(stream);
            System.out.println("content = " + content); // 输出所有文本内容
        } catch (Exception e) {
            e.printStackTrace();
        }finally {
            stream.close();
            System.out.println("file.getTotalSpace() = " + file.getTotalSpace());
        }
    }
}